﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;          //--> Tests unitaire
using INSTA.AI97.BankApp.BLL;   //--> Notre couche métier

namespace INSTA.AI97.BankApp.Tests
{
    [TestFixture]
    class Test_AccountBase
    {
        private AccountBase _account;
        private Customer    _customer;

        /// <summary>
        /// L'attribut [SetUp] fait que cette méthode
        /// va être exécutée avant chaque méthode décorée
        /// avec [Test] de cette classe.
        /// </summary>
        [SetUp]
        public void SetUp()
        { 
            // on crée le Customer de test..
            _customer = new Customer() { Name = "toto", FirstName = "titi" };

            // On crée le compte de test..
            _account = AccountFactory.Create(_customer, 100);
        
        }


        [Test]
        public void Test_Constructor()
        {
            bool success = _account.Holder      == _customer &&
                            _account.Balance    == 100;

            Assert.IsTrue(success);
        }


        [Test]
        public void Test_Method_Deposit_ForPositiveAmount()
        {
            _account.Deposit(1);
            Assert.IsTrue(_account.Balance == 101);
        }

        [Test]
        public void Test_Method_Deposit_ForNegativeAmount()
        {
            _account.Deposit(-1);
            Assert.IsTrue(_account.Balance == 100);
        }



        [Test]
        public void Test_Method_Withdraw_ForPositiveAmount()
        {
            _account.Withdraw(1);
            Assert.IsTrue(_account.Balance == 99);
        }

        [Test]
        public void Test_Method_Withdraw_ForNegativeAmount()
        {
            _account.Withdraw(-1);
            Assert.IsTrue(_account.Balance == 100);
        }




    }
}
